// 订单相关常量定义
import { OrderStatus, PaymentMethod, ExperimentType, SampleShippingMethod, ExpressCompany } from '@/types/order';

// 订单类型常量
export const ORDER_TYPES = {
  SAMPLE_DELIVERY: 'sample_delivery',
  ENGINEER_OPERATION: 'engineer_operation',
  SELF_OPERATION: 'self_operation',
  DEMAND_ORDER: 'demand_order',
} as const;

// 订单类型文本映射
export const ORDER_TYPE_TEXT = {
  [ORDER_TYPES.SAMPLE_DELIVERY]: '送样申请',
  [ORDER_TYPES.ENGINEER_OPERATION]: '仪器预约-工程师操作',
  [ORDER_TYPES.SELF_OPERATION]: '仪器预约-自主操作',
  [ORDER_TYPES.DEMAND_ORDER]: '需求订单',
} as const;

// 订单状态选项
export const ORDER_STATUS_OPTIONS = [
  { label: '待审核', value: OrderStatus.PENDING_REVIEW, color: 'orange' },
  { label: '待确认', value: OrderStatus.PENDING_CONFIRMATION, color: 'blue' },
  { label: '待实验', value: OrderStatus.WAITING_EXPERIMENT, color: 'cyan' },
  { label: '实验中', value: OrderStatus.IN_PROGRESS, color: 'purple' },
  { label: '待结算', value: OrderStatus.PENDING_SETTLEMENT, color: 'gold' },
  { label: '已完成', value: OrderStatus.COMPLETED, color: 'green' },
  { label: '完成（培训通过）', value: OrderStatus.TRAINING_PASSED, color: 'green' },
  { label: '完成（培训不通过）', value: OrderStatus.TRAINING_FAILED, color: 'red' },
  { label: '已驳回', value: OrderStatus.REJECTED, color: 'red' },
  { label: '已关闭', value: OrderStatus.CLOSED, color: 'default' },
  { label: '已取消', value: OrderStatus.CANCELLED, color: 'default' },
  { label: '已退款', value: OrderStatus.REFUNDED, color: 'magenta' },
];

// 订单状态文本映射
export const ORDER_STATUS_TEXT = {
  [OrderStatus.PENDING_REVIEW]: '待审核',
  [OrderStatus.PENDING_CONFIRMATION]: '待确认',
  [OrderStatus.WAITING_EXPERIMENT]: '待实验',
  [OrderStatus.IN_PROGRESS]: '实验中',
  [OrderStatus.PENDING_SETTLEMENT]: '待结算',
  [OrderStatus.COMPLETED]: '已完成',
  [OrderStatus.TRAINING_PASSED]: '完成（培训通过）',
  [OrderStatus.TRAINING_FAILED]: '完成（培训不通过）',
  [OrderStatus.REJECTED]: '已驳回',
  [OrderStatus.CLOSED]: '已关闭',
  [OrderStatus.CANCELLED]: '已取消',
  [OrderStatus.REFUNDED]: '已退款',
};

// 订单状态颜色映射
export const ORDER_STATUS_COLOR = {
  [OrderStatus.PENDING_REVIEW]: 'orange',
  [OrderStatus.PENDING_CONFIRMATION]: 'blue',
  [OrderStatus.WAITING_EXPERIMENT]: 'cyan',
  [OrderStatus.IN_PROGRESS]: 'purple',
  [OrderStatus.PENDING_SETTLEMENT]: 'gold',
  [OrderStatus.COMPLETED]: 'green',
  [OrderStatus.TRAINING_PASSED]: 'green',
  [OrderStatus.TRAINING_FAILED]: 'red',
  [OrderStatus.REJECTED]: 'red',
  [OrderStatus.CLOSED]: 'default',
  [OrderStatus.CANCELLED]: 'default',
  [OrderStatus.REFUNDED]: 'magenta',
} as const;

// 支付方式选项
export const PAYMENT_METHOD_OPTIONS = [
  { label: '个人余额', value: PaymentMethod.PERSONAL_BALANCE },
  { label: '团队余额', value: PaymentMethod.TEAM_BALANCE },
  { label: '团队额度', value: PaymentMethod.TEAM_CREDIT },
];

// 支付方式文本映射
export const PAYMENT_METHOD_TEXT = {
  [PaymentMethod.PERSONAL_BALANCE]: '个人余额',
  [PaymentMethod.TEAM_BALANCE]: '团队余额',
  [PaymentMethod.TEAM_CREDIT]: '团队额度',
};

// 邮寄状态常量
export const SHIPPING_STATUS = {
  NOT_SHIPPED: 'not_shipped',
  SHIPPED: 'shipped',
  RECEIVED: 'received',
  RETURNED: 'returned',
} as const;

// 邮寄状态文本映射
export const SHIPPING_STATUS_TEXT = {
  [SHIPPING_STATUS.NOT_SHIPPED]: '未发货',
  [SHIPPING_STATUS.SHIPPED]: '已发货',
  [SHIPPING_STATUS.RECEIVED]: '已收货',
  [SHIPPING_STATUS.RETURNED]: '已退回',
} as const;

// 实验类型选项
export const EXPERIMENT_TYPE_OPTIONS = [
  { label: '正常实验', value: ExperimentType.NORMAL },
  { label: '培训', value: ExperimentType.TRAINING },
  { label: '试课', value: ExperimentType.COURSE },
  { label: '简求订单', value: ExperimentType.SIMPLE },
];

// 实验类型文本映射
export const EXPERIMENT_TYPE_TEXT = {
  [ExperimentType.NORMAL]: '正常实验',
  [ExperimentType.TRAINING]: '培训',
  [ExperimentType.COURSE]: '试课',
  [ExperimentType.SIMPLE]: '简求订单',
};

// 样品邮寄方式选项
export const SAMPLE_SHIPPING_METHOD_OPTIONS = [
  { label: '自带样品', value: SampleShippingMethod.SELF_DELIVERY },
  { label: '样品邮寄-不需寄回', value: SampleShippingMethod.MAIL_NO_RETURN },
  { label: '样品邮寄-需寄回', value: SampleShippingMethod.MAIL_WITH_RETURN },
];

// 样品邮寄方式文本映射
export const SAMPLE_SHIPPING_METHOD_TEXT = {
  [SampleShippingMethod.SELF_DELIVERY]: '自带样品',
  [SampleShippingMethod.MAIL_NO_RETURN]: '样品邮寄-不需寄回',
  [SampleShippingMethod.MAIL_WITH_RETURN]: '样品邮寄-需寄回',
};

// 快递公司选项
export const EXPRESS_COMPANY_OPTIONS = [
  { label: '顺丰', value: ExpressCompany.SF },
  { label: '圆通', value: ExpressCompany.YTO },
  { label: '中通', value: ExpressCompany.ZTO },
  { label: '申通', value: ExpressCompany.STO },
  { label: 'EMS', value: ExpressCompany.EMS },
  { label: '京东', value: ExpressCompany.JD },
];

// 快递公司文本映射
export const EXPRESS_COMPANY_TEXT = {
  [ExpressCompany.SF]: '顺丰',
  [ExpressCompany.YTO]: '圆通',
  [ExpressCompany.ZTO]: '中通',
  [ExpressCompany.STO]: '申通',
  [ExpressCompany.EMS]: 'EMS',
  [ExpressCompany.JD]: '京东',
};

// 通用操作常量
export const COMMON_ACTIONS = {
  // 财务专用操作
  finance_actions: ['退款', '修改订单金额'],
  
  // 培训相关操作
  training_actions: {
    [OrderStatus.IN_PROGRESS]: ['培训通过', '培训不通过'],
  },
  
  // 其他通用操作
  common_actions: ['修改订单金额', '上传数据', '下载数据', '重新提交'],
};

// 订单状态操作映射（基于状态-操作对照表）
export const ORDER_STATUS_ACTIONS = {
  // 送样申请
  sample_delivery: {
    [OrderStatus.PENDING_REVIEW]: ['通过', '驳回'],
    [OrderStatus.PENDING_CONFIRMATION]: ['关闭订单'],
    [OrderStatus.WAITING_EXPERIMENT]: ['上机', '结算', '关闭订单'],
    [OrderStatus.IN_PROGRESS]: ['下机', '结算', '关闭订单'],
    [OrderStatus.PENDING_SETTLEMENT]: ['结算'],
    [OrderStatus.COMPLETED]: ['上传数据', '退款'],
    [OrderStatus.REJECTED]: ['重新提交'],
    [OrderStatus.CLOSED]: [],
    [OrderStatus.CANCELLED]: [],
    [OrderStatus.REFUNDED]: [],
  },
  
  // 仪器预约-工程师操作
  engineer_operation: {
    [OrderStatus.PENDING_REVIEW]: ['通过', '驳回'],
    [OrderStatus.PENDING_CONFIRMATION]: ['关闭订单'],
    [OrderStatus.WAITING_EXPERIMENT]: ['上机', '关闭订单'],
    [OrderStatus.IN_PROGRESS]: ['下机', '关闭订单'],
    [OrderStatus.PENDING_SETTLEMENT]: ['结算'],
    [OrderStatus.COMPLETED]: ['上传数据', '退款'],
    [OrderStatus.REJECTED]: ['重新提交'],
    [OrderStatus.CLOSED]: [],
    [OrderStatus.CANCELLED]: [],
    [OrderStatus.REFUNDED]: [],
  },
  
  // 仪器预约-自主操作
  self_operation: {
    [OrderStatus.PENDING_REVIEW]: ['通过', '驳回'],
    [OrderStatus.PENDING_CONFIRMATION]: ['关闭订单'],
    [OrderStatus.WAITING_EXPERIMENT]: ['上机', '关闭订单'],
    [OrderStatus.IN_PROGRESS]: ['下机', '关闭订单'],
    [OrderStatus.PENDING_SETTLEMENT]: ['结算'],
    [OrderStatus.COMPLETED]: ['上传数据', '退款'],
    [OrderStatus.TRAINING_PASSED]: ['上传数据', '退款'],
    [OrderStatus.TRAINING_FAILED]: ['上传数据', '退款'],
    [OrderStatus.REJECTED]: ['重新提交'],
    [OrderStatus.CLOSED]: [],
    [OrderStatus.CANCELLED]: [],
    [OrderStatus.REFUNDED]: [],
  },

  // 需求订单
  demand_order: {
    [OrderStatus.PENDING_REVIEW]: ['通过', '驳回'],
    [OrderStatus.PENDING_CONFIRMATION]: ['关闭订单'],
    [OrderStatus.WAITING_EXPERIMENT]: ['结算', '关闭订单'],
    [OrderStatus.IN_PROGRESS]: ['结算', '关闭订单'],
    [OrderStatus.PENDING_SETTLEMENT]: ['结算'],
    [OrderStatus.COMPLETED]: ['退款'],
    [OrderStatus.REJECTED]: ['重新提交'],
    [OrderStatus.CLOSED]: [],
    [OrderStatus.CANCELLED]: [],
    [OrderStatus.REFUNDED]: [],
  },
};

// Tab配置常量
export const TAB_CONFIG = [
  { key: 'all', label: '全部订单' },
  { key: 'pending_review', label: '待审核', status: OrderStatus.PENDING_REVIEW },
  { key: 'pending_confirmation', label: '待确认', status: OrderStatus.PENDING_CONFIRMATION },
  { key: 'waiting_experiment', label: '待实验', status: OrderStatus.WAITING_EXPERIMENT },
  { key: 'in_progress', label: '实验中', status: OrderStatus.IN_PROGRESS },
  { key: 'pending_settlement', label: '待结算', status: OrderStatus.PENDING_SETTLEMENT },
  { key: 'completed', label: '已完成' },
  { key: 'others', label: '已取消/已驳回/关闭' },
]; 